package cn.maihe.elg.operation.common.annotation;

import cn.maihe.elg.operation.common.validator.NumberFmtValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @Description
 * @Author WJH
 * @Date 2021/07/13
 */
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {NumberFmtValidator.class})
public @interface NumberFmt {

    /**
     * @return 保留小数点位数
     */
    int scale() default 0;

    double min() default Double.MIN_VALUE;

    double max() default Double.MAX_VALUE;

    /**
     * @return the error message template
     */
    String message() default "数值格式化失败";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };


}
